<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<base href="<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>模板分类</title>
<script type='text/javascript' src='js/jquery-1.4.2.min.js'></script>
		<script type='text/javascript' src='js/jquery.validate.min.js'></script>
		<script type='text/javascript' src='js/common.js'></script>
<link href="manage/manage.css" rel="stylesheet" type="text/css">
<script type="text/javascript"> 
    
    function deleteBisType(bisId)
	{
	 if(!confirm("您确定要删除该模板分类吗?"))
	 {
	  return;
	 }
	 document.location.href="bisType!delBisType.action?delId="+bisId;
	} 
	 //转至多少页码
	 function changePage(listId)
	 {
	  document.location.href="bisType!allBisTypeListByName.action?pageNo="+listId;
	 } 
	 
	 //编辑显示
	 function updateBisType(updateId)
	 {
	  var tdId="typeName"+updateId;
	  var tyId="edit"+updateId;
	  var cmId="user"+updateId;
	  
	  document.getElementById("updateBis").style.display="inline";
	  document.getElementById("addBis").style.display="none";
	  document.getElementById("updateName").value=document.getElementById(tdId).innerText;
	  
	  var comName=document.getElementById(cmId).value;
	  document.getElementById("listTypeId").value=document.getElementById(tyId).value;
	  document.getElementById("useUsertypeId").value=comName;
	  document.getElementById("upId").value=updateId;
	 }
	 
	 //取消编辑
	 function quxiaoBisGroupType()
	 {
	  document.getElementById("updateBis").style.display="none";
	 }
	 
	 //取消新增
	  function quxiaoAddBisGroupType()
	 {
	  document.getElementById("addBis").style.display="none";
	 }
	 
	 //新增加分组
	 function xinjiaBisGroupType()
	 {
	  document.getElementById("addBis").style.display="inline";
	  document.getElementById("updateBis").style.display="none";
	 }
	 
	 //保存编辑
	 function updateAddBisGroupType()
	 {
	  var bgName=document.getElementById("updateName").value;
	  if(bgName.trim()=="")
	  {
	    alert("请输入分类名称");
	    return;
	  }
	  $("#updateForm").submit();
	 }
	 
	 //保存分组
	 function addBisGroupType()
	 {
	  var adName=document.getElementById("addName").value;
	  if(adName.trim()=="")
	  {
	    alert("请输入分组名称");
	    return;
	  }
	  $("#addForm").submit();
	 }
	 
	 function serachBG()
	 {
	 $("#serachGroupTypeForm").submit();
	 }
</script>
</head>
<body style="margin:0px; text-align:center;font-size:12px;" bgcolor="#F1F1F1" >
<div id="top">
 	<!-- 头部-->
 	<%@include file="mainTop.jsp"%>
</div>
<div id="top2"></div>

<!-- 中间-->
<div id="main1">
<!-- 左边-->
 <%@include file="mainLeft.jsp"%>
 <div class="mainr2">
<table width="789" height="500" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">

  <tr>
    <td height="500" align="left" valign="top">
	<table width="788" height="70" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px solid #DBDBDB; border-left:1px solid #DBDBDB;  " >
      <tr style="font-size:12px">
        <td width="112" align="center" background="images/line3.jpg"  style="border:1px solid #DBDBDB;"><a href="mobanListAction!list.action">模板列表</a></td>
        <td width="6" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
        <td width="110" align="center" background="images/line3.jpg"  style="border:1px solid #DBDBDB;"><a href="mobanAction!addMoban.action?first=1">新建模块</a></td>
        <td width="7" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
		 	<td width="112" height="22" align="center" bgcolor="#FFFFFF" style="border-top:1px solid #DBDBDB; border-right:1px solid #DBDBDB;" >模块分类</td>
        <td width="8" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
       <td width="110" align="center" background="images/line3.jpg" style="border:1px solid #DBDBDB; "><a href="bisGroup!allBisGroupListByName.action">模块分组</a></td>
        <td width="8" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
        
        <td width="110" align="center" background="images/line3.jpg" style="border:1px solid #DBDBDB; "><a href="bisGroup!allBisGroupListByName.action">还可能发送</a></td>
        <td width="250px" style="border-bottom:1px solid #DBDBDB;">&nbsp;</td>
      </tr>
	  
      <tr>
        <td height="47" colspan="10" align="center" valign="top" style="border-right:1px solid #FFFFFF">
		<table width="780" height="42" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="font-size:12px">
          <tr  align="left">
            <td height="42"  valign="middle" class="STYLE20">
            <s:form name="serachGroupTypeForm" id="serachGroupTypeForm" action="bisType!serachBisGroupType.action" method="post">
			 <table width="528" height="51" border="0" cellpadding="0" cellspacing="0" style="font-size:12px;" bgcolor="#FFFFFF">
				  <tr>
                    <td width="94" align="right">分类名称:</td>
                    <td width="168" align="left">
                    <input type="text" name="typeName" id="typeName" value="${typeName}"></td>
                    <td width="266"><img src="images/ck.jpg" width="42" height="21" onClick="serachBG();"></td>
                  </tr>
                </table>		
				</s:form>
			    </td>
              </tr>
            </table>          </td>
        </tr>
        </table>
        <s:if test="pageObj.data.size()>0"><!-- 如果有模块分组列表显示数据 -->
          <table width="787"  border="0" cellpadding="0" cellspacing="0" style="font-size:12px">
            <tr>
              <td width="186" height="29" align="center" background="images/lm1_bg.jpg">分类名称</td>
              <td width="11" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="251" align="center" background="images/lm1_bg.jpg">分类属性</td>
              <td width="11" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="167" align="center" background="images/lm1_bg.jpg">可使用会员属性</td>
              <td width="11" align="center" background="images/lm1_bg.jpg"><img src="images/line2.jpg" width="10" height="25" /></td>
              <td width="150" align="center" background="images/lm1_bg.jpg">操作</td>
            </tr>
             <!-- 开始数据显示 -->
            <s:iterator value="pageObj.data" var="disType" status="st">
            <s:if test="#st.odd"><tr bgcolor="#FFFFFF"></s:if>
            <s:else> <tr bgcolor="#F7F7F7"></s:else>
             <td height="30" align="center" id="typeName${disType.id}">${disType.name}</td>
              <td>&nbsp;</td>
              <td align="center" >
              <input type="hidden" id="edit${disType.id}" value="${disType.editAble}"/>
              &nbsp;&nbsp;
              <s:if test="#disType.editAble==0"><font color="red">不可编辑文字</font></s:if>
              <s:else>可编辑文字</s:else>
              </td>
              <td>&nbsp;</td>
              <td align="center" >
              <input type="hidden" id="user${disType.id}" value="${disType.useUsertype}"/>
                 <s:if test="#disType.useUsertype==0">全部会员</s:if>
                  <s:if test="#disType.useUsertype==1">普通会员</s:if>
                 <s:if test="#disType.useUsertype==2"><font color="red">Vip会员</font></s:if>
              </td>
              <td align="center">&nbsp;</td>
              <td align="center"><a href="javaScript:updateBisType('${disType.id}');" >编辑</a>|<a href="javaScript:deleteBisType('${disType.id}');">删除</a></td>
            </tr>
            
            </s:iterator>
            
			<!--编辑字段时候显示-->
			<s:form name="updateForm" id="updateForm" action="bisType!updateBisGroupType.action" method="post">
      <tr bgcolor="#FFFFFF" style="display:none" id="updateBis" >
              <td height="30" align="center"><input type="text" size="10" name="updateName" id="updateName" style="text-align: center" ></td>
              <td class="lbsx STYLE21">&nbsp;<input type="hidden" id="upId" name="upId"/><input type="hidden" id="pageId" name="pageId" value="${pageObj.pageNo}"/></td>
              <td align="center" class="lbsx">
                 <s:select list="#{0:'不可编辑文字',1:'可编辑文字'}" id="listTypeId" name="listTypeId">
                 </s:select>
               </td>
              <td>&nbsp;</td>
              <td align="center">
                 <s:select list="#{0:'全部会员',1:'普通会员',2:'Vip会员'}" id="useUsertypeId" name="useUsertypeId" > 
                 </s:select>
             </td>
              <td align="center" >&nbsp;</td>
              <td align="center"><a href="javaScript:updateAddBisGroupType();">保存</a>|<a href="javaScript:quxiaoBisGroupType();">取消</a></td>
            </tr>
			</s:form>
			
			<!--新增字段时候显示-->
			<s:form name="addForm" id="addForm" action="bisType!addBisType.action" method="post">
			 <tr bgcolor="#FFFFFF" style="display:none" id="addBis" >
              <td height="30" align="center"><input type="text" size="10" name="addName" id="addName" style="text-align: center" ></td>
              <td class="lbsx STYLE21">&nbsp;</td>
              <td align="center" class="lbsx">
                <s:select list="#{0:'不可编辑文字',1:'可编辑文字'}" id="addTypeId" name="addTypeId">
                 </s:select>
               </td>
              <td>&nbsp;</td>
              <td align="center">
                 <s:select list="#{0:'全部会员',1:'普通会员',2:'Vip会员'}" id="adduserId" name="adduserId" > 
                 </s:select>
             </td>
              <td align="center" >&nbsp;</td>
              <td align="center"><a href="javaScript:addBisGroupType();">增加</a>|<a href="javaScript:quxiaoAddBisGroupType();">取消</a></td>
            </tr>
			</s:form>
            <tr>
            <s:if test="pageObj.totalRecord>10">
               <td height="29" align="right" background="images/lm1_bg.jpg" ><a href="javaScript:xinjiaBisGroupType();" >添加新分类</a></td>
               <td height="29" colspan="8" align="right" background="images/lm1_bg.jpg" >
              <a href="bisType!allBisTypeListByName.action?pageNo=1">首页</a>&nbsp;
                <s:if test="pageObj.hasPrePage==false" >上一页</s:if>
                <s:else> <a href="bisType!allBisTypeListByName.action?pageNo=<s:property value="pageObj.pageNo-1"/>">上一页</a></s:else>
   
              &nbsp;<s:if test="pageObj.hasNextPage==false">下一页</s:if>
              <s:else> <a href="bisType!allBisTypeListByName.action?pageNo=<s:property value="pageObj.pageNo+1"/>" >下一页</a></s:else>
              
              &nbsp; <s:if test="pageObj.pageNo==pageObj.totalPage">末页</s:if>
       <s:else><a href="bisType!allBisTypeListByName.action?pageNo=<s:property value="pageObj.totalPage"/>" >末页</a></s:else>

              
              &nbsp;&nbsp;第${pageObj.pageNo}页
              &nbsp;|&nbsp;共${pageObj.totalPage}页&nbsp;|&nbsp;共${pageObj.totalRecord}条 转至
            <s:select list="pageObj.listNum" onchange="changePage(this.value)" id="pageNo" name="pageNo">
            </s:select>
               </td>
               </s:if>
               <s:else> 
               <td height="29" colspan="6" background="images/lm1_bg.jpg" >&nbsp;</td>
                <td height="29"  align="center" background="images/lm1_bg.jpg"  ><a href="javaScript:xinjiaBisGroupType();">添加新分类</a></td>
            </s:else>
            </tr>
      </table>
      </s:if>  
      <s:else>
        <p style="color: red;font-size: 12px;text-align: center;">您还没有增加模块分类相关信息!</p>
      </s:else>
      </td>
      </tr>
    </table></td>
  </tr>
</table></td>
  </tr>
</table></td>
  </tr>
</table></td>
  </tr>
 </div>

</div>


</body>
</html>
